﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Timers;
using RxjhServer.DbClss;
using RxjhServer.HelperTools;
using RxjhServer.Network;

namespace RxjhServer
{
	public class NpcClass : IDisposable
	{
		private Random Randomd = new Random();

		private object AsyncLock = new object();

		private object HitLock = new object();

		private object AsyncLocksw = new object();

		private ThreadSafeDictionary<int, Players> PlayList;

		private Dictionary<int, NpcClass> NpcList;

		private ArrayList tem = new ArrayList();

		private List<PlayGjClass> PlayGjList = new List<PlayGjClass>();

		private ThreadSafeDictionary<int, PlayZDClass> 组队列表 = new ThreadSafeDictionary<int, PlayZDClass>();

		private object thisLock1 = new object();

		private object thisLock2 = new object();

		public System.Timers.Timer 自动移动;

		public System.Timers.Timer 自动攻击;

		public System.Timers.Timer 自动复活;

		public static Random Ran = new Random();

		private Random publicRan = new Random();

		private float _FLD_FACE1;

		private float _FLD_FACE2;

		private int _IsNpc;

		private string _Name;

		private int _FLD_INDEX;

		private int _FLD_PID;

		private double _FLD_AT;

		private float _Rxjh_X;

		private float _Rxjh_Y;

		private float _Rxjh_Z;

		private float _Rxjh_cs_X;

		private float _Rxjh_cs_Y;

		private float _Rxjh_cs_Z;

		private int _Rxjh_Map;

		private int _Rxjh_Exp;

		private int _Max_Rxjh_HP;

		private int _Rxjh_HP;

		private int _Level;

		private double _FLD_DF;

		private int _FLD_AUTO;

		private int _FLD_BOSS;

		private int _FLD_NEWTIME;

		private bool _NPC死亡;

		private bool _一次性怪;

		public void PlayList_Add(Players payer)
		{
			this.PlayList.Add(payer.人物全服ID, payer);
		}

		public void PlayList_Remove(Players payer)
		{
			this.PlayList.Remove(payer.人物全服ID);
		}

		public bool Contains(Players payer)
		{
			return this.PlayList.ContainsKey(payer.人物全服ID);
		}

		public void Play_Add(Players payer)
		{
			foreach (PlayGjClass current in this.PlayGjList)
			{
				if (current.PlayID == payer.人物全服ID)
				{
					current.Gjsl++;
					return;
				}
			}
			PlayGjClass playGjClass = new PlayGjClass();
			playGjClass.Hitsl = 0;
			playGjClass.Gjsl = 1;
			playGjClass.PlayID = payer.人物全服ID;
			playGjClass.HitPlayID = payer.人物全服ID;
			this.PlayGjList.Add(playGjClass);
		}

		public void Play_Hit(Players payer, int 攻击数量)
		{
			using (new Lock(this.HitLock, "Play_Hit"))
			{
				if (this.Rxjh_HP < 0)
				{
					攻击数量 += this.Rxjh_HP;
				}
				if (攻击数量 >= 0)
				{
					foreach (PlayGjClass current in this.PlayGjList)
					{
						if (current.PlayID == payer.人物全服ID)
						{
							current.Hitsl += 攻击数量;
							break;
						}
						if (payer.人物灵兽 != null && current.HitPlayID == payer.人物灵兽.全服ID)
						{
							current.Hitsl += 攻击数量;
							break;
						}
					}
					if (payer.组队id != 0 && !this.组队列表.ContainsKey(payer.组队id))
					{
						PlayZDClass playZDClass = new PlayZDClass();
						playZDClass.dwID = payer.组队id;
						playZDClass.Hitsl = 0;
						this.组队列表.Add(playZDClass.dwID, playZDClass);
					}
				}
			}
		}

		public void Play_Add(Players payer, 灵兽类 pat)
		{
			foreach (PlayGjClass current in this.PlayGjList)
			{
				if (current.HitPlayID == pat.全服ID)
				{
					current.Gjsl++;
					return;
				}
			}
			PlayGjClass playGjClass = new PlayGjClass();
			playGjClass.Hitsl = 0;
			playGjClass.Gjsl = 1;
			playGjClass.PlayID = payer.人物全服ID;
			playGjClass.HitPlayID = pat.全服ID;
			this.PlayGjList.Add(playGjClass);
		}

		public void Play_null()
		{
			try
			{
				if (this.PlayGjList.Count > 0)
				{
					this.PlayGjList.Clear();
				}
				if (this.组队列表.Count > 0)
				{
					this.组队列表.Clear();
				}
			}
			catch
			{
			}
		}

		public int PlayerWid
		{
			get
			{
				if (this.PlayGjList.Count <= 0)
				{
					return 0;
				}
				int result;
				try
				{
					PlayGjClass playGjClass = new PlayGjClass();
					Reverser<PlayGjClass> comparer = new Reverser<PlayGjClass>(playGjClass.GetType(), "Gjsl", ReverserInfo.Direction.DESC);
					this.PlayGjList.Sort(comparer);
					result = this.PlayGjList[0].HitPlayID;
				}
				catch (Exception)
				{
					result = 0;
				}
				return result;
			}
		}

		public int UserPlayerWid
		{
			get
			{
				if (this.PlayGjList.Count <= 0)
				{
					return 0;
				}
				int result;
				try
				{
					PlayGjClass playGjClass = new PlayGjClass();
					Reverser<PlayGjClass> comparer = new Reverser<PlayGjClass>(playGjClass.GetType(), "Gjsl", ReverserInfo.Direction.DESC);
					this.PlayGjList.Sort(comparer);
					result = this.PlayGjList[0].PlayID;
				}
				catch (Exception)
				{
					result = 0;
				}
				return result;
			}
		}

		public int BossPlayerWid
		{
			get
			{
				if (this.PlayGjList.Count <= 0)
				{
					return 0;
				}
				int result;
				try
				{
					int num = 0;
					int index;
					while (true)
					{
						Random random = new Random();
						index = random.Next(0, this.PlayGjList.Count);
						int num2 = this.Max_Rxjh_HP / this.PlayGjList.Count;
						if (this.PlayGjList[index].Hitsl >= num2)
						{
							goto IL_A6;
						}
						if (num > this.PlayGjList.Count)
						{
							break;
						}
						num++;
					}
					PlayGjClass playGjClass = new PlayGjClass();
					Reverser<PlayGjClass> comparer = new Reverser<PlayGjClass>(playGjClass.GetType(), "Gjsl", ReverserInfo.Direction.DESC);
					this.PlayGjList.Sort(comparer);
					result = this.PlayGjList[0].PlayID;
					return result;
					IL_A6:
					result = this.PlayGjList[index].PlayID;
				}
				catch (Exception)
				{
					result = 0;
				}
				return result;
			}
		}

		public NpcClass()
		{
			this.PlayList = new ThreadSafeDictionary<int, Players>();
			this.NpcList = new Dictionary<int, NpcClass>();
			double interval = (double)NpcClass.Ran.Next(3000, 15000);
			this.自动移动 = new System.Timers.Timer(interval);
			this.自动移动.Elapsed += new ElapsedEventHandler(this.自动移动事件);
			this.自动移动.AutoReset = true;
			this.自动移动.Enabled = true;
			this.自动攻击 = new System.Timers.Timer(1000.0);
			this.自动攻击.Elapsed += new ElapsedEventHandler(this.自动攻击事件);
			this.自动攻击.AutoReset = true;
		}

		public void 获取范围玩家发送增加数据包()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_获取范围玩家发送增加数据包");
			}
			try
			{
				foreach (Players current in World.allConnectedChars.Values)
				{
					if (this.查找范围玩家(400, current))
					{
						current.获取复查范围Npc();
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "获取范围玩家发送地面增加Npc数据包 出错：" + arg);
			}
		}

		public void Dispose()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_Dispose");
			}
			try
			{
				MapClass.delnpc(this.Rxjh_Map, this.FLD_INDEX);
				if (this.自动攻击 != null)
				{
					this.自动攻击.Enabled = false;
					this.自动攻击.Close();
					this.自动攻击.Dispose();
				}
				if (this.自动移动 != null)
				{
					this.自动移动.Enabled = false;
					this.自动移动.Close();
					this.自动移动.Dispose();
				}
				if (this.自动复活 != null)
				{
					this.自动复活.Enabled = false;
					this.自动复活.Close();
					this.自动复活.Dispose();
					this.自动复活 = null;
				}
				this.Play_null();
				this.获取范围玩家发送消失数据包();
				this.NpcList.Clear();
				this.tem.Clear();
				if (this.PlayList != null)
				{
					this.PlayList.Dispose();
					this.PlayList = null;
				}
				if (this.NpcList != null)
				{
					this.NpcList = null;
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "NPC 关闭数据Dispose() 出错：" + arg);
			}
		}

		public void 获取范围玩家发送消失数据包()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_获取范围玩家发送消失数据包");
			}
			try
			{
				foreach (Players current in this.PlayList.Values)
				{
					current.获取复查范围Npc();
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "NPC 获取范围玩家发送消失数据包3 出错：" + arg);
			}
		}

		~NpcClass()
		{
		}

		public float FLD_FACE1
		{
			get
			{
				return this._FLD_FACE1;
			}
			set
			{
				this._FLD_FACE1 = value;
			}
		}

		public float FLD_FACE2
		{
			get
			{
				return this._FLD_FACE2;
			}
			set
			{
				this._FLD_FACE2 = value;
			}
		}

		public int IsNpc
		{
			get
			{
				return this._IsNpc;
			}
			set
			{
				this._IsNpc = value;
			}
		}

		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				this._Name = value;
			}
		}

		public int FLD_INDEX
		{
			get
			{
				return this._FLD_INDEX;
			}
			set
			{
				this._FLD_INDEX = value;
			}
		}

		public int FLD_PID
		{
			get
			{
				return this._FLD_PID;
			}
			set
			{
				this._FLD_PID = value;
			}
		}

		public double FLD_AT
		{
			get
			{
				return this._FLD_AT;
			}
			set
			{
				this._FLD_AT = value;
			}
		}

		public float Rxjh_X
		{
			get
			{
				return this._Rxjh_X;
			}
			set
			{
				this._Rxjh_X = value;
			}
		}

		public float Rxjh_Y
		{
			get
			{
				return this._Rxjh_Y;
			}
			set
			{
				this._Rxjh_Y = value;
			}
		}

		public float Rxjh_Z
		{
			get
			{
				return this._Rxjh_Z;
			}
			set
			{
				this._Rxjh_Z = value;
			}
		}

		public float Rxjh_cs_X
		{
			get
			{
				return this._Rxjh_cs_X;
			}
			set
			{
				this._Rxjh_cs_X = value;
			}
		}

		public float Rxjh_cs_Y
		{
			get
			{
				return this._Rxjh_cs_Y;
			}
			set
			{
				this._Rxjh_cs_Y = value;
			}
		}

		public float Rxjh_cs_Z
		{
			get
			{
				return this._Rxjh_cs_Z;
			}
			set
			{
				this._Rxjh_cs_Z = value;
			}
		}

		public int Rxjh_Map
		{
			get
			{
				return this._Rxjh_Map;
			}
			set
			{
				this._Rxjh_Map = value;
			}
		}

		public int Rxjh_Exp
		{
			get
			{
				return this._Rxjh_Exp;
			}
			set
			{
				this._Rxjh_Exp = value;
			}
		}

		public int Max_Rxjh_HP
		{
			get
			{
				return this._Max_Rxjh_HP;
			}
			set
			{
				this._Max_Rxjh_HP = value;
			}
		}

		public int Rxjh_HP
		{
			get
			{
				return this._Rxjh_HP;
			}
			set
			{
				this._Rxjh_HP = value;
			}
		}

		public int Level
		{
			get
			{
				return this._Level;
			}
			set
			{
				this._Level = value;
			}
		}

		public double FLD_DF
		{
			get
			{
				return this._FLD_DF;
			}
			set
			{
				this._FLD_DF = value;
			}
		}

		public int FLD_AUTO
		{
			get
			{
				return this._FLD_AUTO;
			}
			set
			{
				this._FLD_AUTO = value;
			}
		}

		public int FLD_BOSS
		{
			get
			{
				return this._FLD_BOSS;
			}
			set
			{
				this._FLD_BOSS = value;
			}
		}

		public int FLD_NEWTIME
		{
			get
			{
				return this._FLD_NEWTIME;
			}
			set
			{
				this._FLD_NEWTIME = value;
			}
		}

		public bool NPC死亡
		{
			get
			{
				return this._NPC死亡;
			}
			set
			{
				this._NPC死亡 = value;
			}
		}

		public bool 一次性怪
		{
			get
			{
				return this._一次性怪;
			}
			set
			{
				this._一次性怪 = value;
			}
		}

		public void getbl()
		{
			if (this.PlayList.Count > 0)
			{
				Form1.WriteLine(2, this._Name + " 人物：" + this.PlayList.Count);
				if (this.自动移动 != null)
				{
					Form1.WriteLine(2, this._Name + " 人物_自动移动：" + this.自动移动.Enabled);
				}
				if (this.自动攻击 != null)
				{
					Form1.WriteLine(2, this._Name + " 人物_自动攻击：" + this.自动攻击.Enabled);
				}
				if (this.自动复活 != null)
				{
					Form1.WriteLine(2, this._Name + " 人物_自动复活：" + this.自动复活.Enabled);
				}
			}
			if (this.NpcList.Count > 0)
			{
				Form1.WriteLine(2, this._Name + " NPC：" + this.NpcList.Count);
			}
			if (this.PlayGjList.Count > 0)
			{
				Form1.WriteLine(2, this._Name + " 攻击：" + this.PlayGjList.Count);
			}
		}
        public int 队伍范围内单职业人数(组队Class 组队a)
        {
            int num = 0;
            try
            {
                foreach (Players value in 组队a.组队列表.Values)
                {
                    if (查找范围玩家(World.组队范围, value) && value.人物_HP > 0 && !value.Player死亡 && value.Player_Job != 1)
                    {
                        num++;
                    }
                }
                return num;
            }
            catch
            {
                return 0;
            }
        }
        public bool 是否全职业(组队Class 组队, out int 附近人数, out int 附近组队人数)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			int num7 = 0;
			foreach (Players current in 组队.组队列表.Values)
			{
				if (this.查找范围玩家(World.组队范围, current))
				{
					if (this.查找范围玩家(World.组队范围, current))
					{
						num6++;
						if (current.Player_Job == 5)
						{
							num2++;
						}
						else if (current.Player_Job == 4)
						{
							num++;
						}
						else if (current.Player_Job == 3)
						{
							num3++;
						}
						else if (current.Player_Job == 2)
						{
							num4++;
						}
						else if (current.Player_Job == 1)
						{
							num5++;
						}
					}
					num7++;
				}
			}
			附近人数 = num6;
			附近组队人数 = num7;
			return num != 0 && num2 != 0 && num3 != 0 && num4 != 0 && num5 != 0;
		}

		public void 获得分配经验()
		{
			if (this.Rxjh_Exp <= 0)
			{
				return;
			}
          

			double num = World.经验倍数;
			if (World.是否开启高倍经验 == 1)
			{
				num *= World.高倍经验倍数;
			}
			double num2 = (double)this.Rxjh_Exp * num;
			int maxValue = (int)(num2 / 10.0);
            //double num3 = num2 + (double)this.publicRan.Next(0, maxValue);
            double num3 = num2;
            int num4 = (int)((double)this.Rxjh_Exp * World.钱倍数 / 20.0);
			int num5 = num4 / 3;
			double num6 = (double)this.publicRan.Next(num4 - num5, num4 + num5);
			double num7 = (double)this.Rxjh_Exp * World.历练倍数 / (double)this.Level / 2.0;
			int maxValue2 = (int)(num7 / 3.0);
			double num8 = num7 + (double)this.publicRan.Next(0, maxValue2);
			if (this.Rxjh_Map == 1301 || this.Rxjh_Map == 2001 )
			{
				num3 *= World.南明湖经验倍数;
			}
            else if (this.Rxjh_Map == 5001)
            {
                num3 *= World.北海经验倍数;
            }
            foreach (PlayGjClass current in this.PlayGjList)
			{
				Players players;
				if (World.allConnectedChars.TryGetValue(current.PlayID, out players))
				{
					if (players.组队id != 0)
					{
						组队Class 组队Class;
						if (World.W组队.TryGetValue(players.组队id, out 组队Class))
						{
							if (组队Class.组队列表.ContainsKey(players.人物全服ID))
							{
								using (IEnumerator<PlayZDClass> enumerator2 = this.组队列表.Values.GetEnumerator())
								{
									while (enumerator2.MoveNext())
									{
										PlayZDClass current2 = enumerator2.Current;
										if (players.组队id == current2.dwID)
										{
											if (this.查找范围玩家(World.组队范围, players))
											{
												current2.Hitsl += current.Hitsl;
												break;
											}
											break;
										}
									}
									continue;
								}
							}
							if (this.查找范围玩家(World.组队范围, players) && players.Player_Level - this.Level < 10)
							{
								double num9 = num3 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
								double num10 = 1.0 + num8 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
								double num11 = 1.0 + num6 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
								if (players.检查公有药品())
								{
									num9 += num9 * 0.2;
									num10 += num10 * 0.5;
									num11 += num11 * 0.2;
								}
								if (players.Player_Level < 35)
								{
									num9 *= World.三十五级以下经验倍数;
									num11 *= 2.0;
								}
								else if (players.Player_Level < 60)
								{
									num9 *= World.六十级以下经验倍数;
									num11 *= 1.0;
								}
								else if (players.Player_Level < 80)
								{
									num9 *= World.八十级以下经验倍数;
									num11 /= 1.5;
								}
								else if (players.Player_Level < 90)
								{
									num9 *= World.九十级以下经验倍数;
									num11 /= 1.5;
								}
								else if (players.Player_Level < 100)
								{
									num9 *= World.百级以下经验倍数;
									num11 /= 2.0;
								}
								else
								{
									num11 /= 2.5;
								}
								if (players.Player_Level - this.Level >= World.人怪等级差最小限制)
								{
									num11 /= 2.0;
								}
       
								players.人物获得经验(num9 * (1.0 + players.人物_追加_经验百分比));
								players.Player_ExpErience += (int)(num10 * (1.0 + players.FLD_人物_追加_历练百分比));
								players.人物获得金币((int)(num11 * (1.0 + players.人物_追加_金钱百分比)), 1);
								players.得到钱的提示((uint)(num11 * (1.0 + players.人物_追加_金钱百分比)));
								players.计算人物基本数据3();
								players.更新经验和历练();
								players.更新金钱和负重();
							}
						}
						else if (this.查找范围玩家(World.组队范围, players) && players.Player_Level - this.Level < 10 && players.Player_LockState != 0)
						{
							double num12 = num3 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
							double num13 = 1.0 + num8 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
							double num14 = 1.0 + num6 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
							if (players.检查公有药品())
							{
								num12 += num12 * 0.2;
								num13 += num13 * 0.5;
								num14 += num14 * 0.2;
							}
							if (players.Player_Level < 35)
							{
								num12 *= World.三十五级以下经验倍数;
								num14 *= 2.0;
							}
							else if (players.Player_Level < 60)
							{
								num12 *= World.六十级以下经验倍数;
								num14 *= 1.0;
							}
							else if (players.Player_Level < 80)
							{
								num12 *= World.八十级以下经验倍数;
								num14 /= 1.5;
							}
							else if (players.Player_Level < 90)
							{
								num12 *= World.九十级以下经验倍数;
								num14 /= 1.5;
							}
							else if (players.Player_Level < 100)
							{
								num12 *= World.百级以下经验倍数;
								num14 /= 2.0;
							}
							if (players.Player_Level - this.Level >= World.人怪等级差最小限制)
							{
								num14 /= 2.0;
							}
							else
							{
								num14 /= 2.5;
							}
							players.人物获得经验(num12 * (1.0 + players.人物_追加_经验百分比));
							players.Player_ExpErience += (int)(num13 * (1.0 + players.FLD_人物_追加_历练百分比));
							players.人物获得金币((int)(num14 * (1.0 + players.人物_追加_金钱百分比)), 1);
							players.得到钱的提示((uint)(num14 * (1.0 + players.人物_追加_金钱百分比)));
							players.计算人物基本数据3();
							players.更新经验和历练();
							players.更新金钱和负重();
						}
					}
					else if (this.查找范围玩家(World.组队范围, players) && players.Player_Level - this.Level < 10 && players.Player_LockState != 0)
					{
						double num15 = num3 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
						double num16 = 1.0 + num8 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
						double num17 = 1.0 + num6 * (double)current.Hitsl / (double)this.Max_Rxjh_HP;
						if (players.检查公有药品())
						{
							num15 += num15 * 0.2;
							num16 += num16 * 0.5;
							num17 += num17 * 0.2;
						}
						if (players.Player_Level < 35)
						{
							num15 *= World.三十五级以下经验倍数;
							num17 *= 2.0;
						}
						else if (players.Player_Level < 60)
						{
							num15 *= World.六十级以下经验倍数;
							num17 *= 1.0;
						}
						else if (players.Player_Level < 80)
						{
							num15 *= World.八十级以下经验倍数;
							num17 /= 1.5;
						}
						else if (players.Player_Level < 90)
						{
							num15 *= World.九十级以下经验倍数;
							num17 /= 1.5;
						}
						else if (players.Player_Level < 100)
						{
							num15 *= World.百级以下经验倍数;
							num17 /= 2.0;
						}
						else
						{
							num17 /= 2.5;
						}
						if (players.Player_Level - this.Level >= World.人怪等级差最小限制)
						{
							num17 /= 2.0;
						}
						players.人物获得经验(num15 * (1.0 + players.人物_追加_经验百分比));
						players.Player_ExpErience += (int)(num16 * (1.0 + players.FLD_人物_追加_历练百分比));
						players.人物获得金币((int)(num17 * (1.0 + players.人物_追加_金钱百分比)), 1);
						players.得到钱的提示((uint)(num17 * (1.0 + players.人物_追加_金钱百分比)));
						players.计算人物基本数据3();
						players.更新经验和历练();
						players.更新金钱和负重();
					}
				}
			}
			foreach (PlayZDClass current3 in this.组队列表.Values)
			{
				组队Class 组队Class2;
				if (World.W组队.TryGetValue(current3.dwID, out 组队Class2))
				{
                    int 组队数量 = 0;
                    foreach (Players players2 in 组队Class2.组队列表.Values)
                    {
                        if ((this.查找范围玩家(World.组队范围, players2) && (players2.人物_HP > 0)) && (!players2.Player死亡))
                        {
                            组队数量++;
                        }
                    }
                    if(组队数量==0)
                    {
                        组队数量 = 1;
                    }
                    int num18 = 0;
					int num19 = 0;
                    int num10 = 队伍范围内单职业人数(组队Class2);
                    bool flag = this.是否全职业(组队Class2, out num18, out num19);
					foreach (Players current4 in 组队Class2.组队列表.Values)
					{
						if (this.查找范围玩家(World.组队范围, current4) && current3.dwID == current4.组队id && current4.Player_Level - this.Level < 10 && !current4.Player死亡 && current4.Player_LockState != 0)
						{

							double num20 = num3 * (double)current3.Hitsl / (double)this.Max_Rxjh_HP * (1.0 + (double)组队数量 * 0.1)  / (double)组队数量;
							double num21 = 1.0 + num8 * (double)current3.Hitsl / (double)this.Max_Rxjh_HP * (1.0 + (double)组队数量 * 0.1)  / (double)组队数量;
							double num22 = 1.0 + num6 * (double)current3.Hitsl / (double)this.Max_Rxjh_HP * (1.0 + (double)组队数量 * 0.1)  / (double)组队数量;
  
                            if (组队数量 == 1)
                            {
                                num20 = num3 * (double)current3.Hitsl / (double)this.Max_Rxjh_HP;
                                num21 = num8 * (double)current3.Hitsl / (double)this.Max_Rxjh_HP;
                                num22 = num6 * (double)current3.Hitsl / (double)this.Max_Rxjh_HP;
                            }
                            else if (组队数量 == 8)
                            {
                                num20 += num20 * 0.64;
							}
							else if (组队数量 == 7)
							{
								num20 += num20 * 0.38;
							}
							else if (组队数量 == 6)
							{
								num20 += num20 * 0.22;
							}
							else if (组队数量 == 5)
							{
								num20 += num20 * 0.1;
							}
							if (current4.检查公有药品())
							{
								num20 += num20 * 0.2;
								num21 += num21 * 0.5;
								num22 += num22 * 0.2;
							}
							if (current4.Player_Level < 35)
							{
								num20 *= World.三十五级以下经验倍数;
								num22 *= 2.0;
							}
							else if (current4.Player_Level < 60)
							{
								num20 *= World.六十级以下经验倍数;
								num22 *= 1.0;
							}
							else if (current4.Player_Level < 80)
							{
								num20 *= World.八十级以下经验倍数;
								num22 /= 1.5;
							}
							else if (current4.Player_Level < 90)
							{
								num20 *= World.九十级以下经验倍数;
								num22 /= 1.5;
							}
							else if (current4.Player_Level < 100)
							{
								num20 *= World.百级以下经验倍数;
								num22 /= 2.0;
							}
							else
							{
								num22 /= 2.5;
							}
							if (flag)
							{
								num20 += num20 * 0.02 * (double)组队数量;
							}
                            if (num10 >= 1)
                            {
                                num20 += (double)num10 * World.队伍单职业经验加成百分比;
                            }
                            if (current4.Player_Level - this.Level >= World.人怪等级差最小限制)
							{
								num22 /= 2.0;
							}
							current4.人物获得经验(num20 * (1.0 + current4.人物_追加_经验百分比));
							current4.Player_ExpErience += (int)(num21 * (1.0 + current4.FLD_人物_追加_历练百分比));
							current4.人物获得金币((int)(num22 * (1.0 + current4.人物_追加_金钱百分比)), 1);
							current4.得到钱的提示((uint)(num22 * (1.0 + current4.人物_追加_金钱百分比)));
							current4.计算人物基本数据3();
							current4.更新经验和历练();
							current4.更新金钱和负重();
						}
					}
				}
			}
		}

		private void 自动移动事件(object source, ElapsedEventArgs e)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "自动移动事件");
			}
			try
			{
				if (this.IsNpc != 0)
				{
					this.自动移动.Enabled = false;
				}
				else
				{
					if (this.NpcList.Count > 0)
					{
						this.NpcList.Clear();
					}
					if (this.PlayList.Count >= 1)
					{
						if (!this.NPC死亡)
						{
							if (this.IsNpc != 1 && this.FLD_AT > 0.0)
							{
								Random random = new Random();
								int num = random.Next(3000, 5000);
								this.自动移动.Interval = (double)num;
								if (this.FLD_AUTO == 1 && this.获取范围玩家())
								{
									this.自动移动.Enabled = false;
									this.自动攻击.Enabled = true;
								}
								else
								{
									this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 30, 1);
								}
							}
							else
							{
								this.自动移动.Interval = 20000.0;
								foreach (Players current in this.PlayList.Values)
								{
									if (current.Client != null)
									{
										if (!World.allConnectedChars.ContainsKey(current.Client.WorldId))
										{
											this.tem.Add(current);
										}
									}
									else
									{
										this.tem.Add(current);
									}
								}
								foreach (Players players in this.tem)
								{
									Form1.WriteLine(2, string.Concat(new object[]
									{
										"NPC广播数据 删除卡号人物：[",
										players.Userid,
										"] [",
										players.UserName,
										"]",
										this.FLD_INDEX
									}));
									if (players.Client != null)
									{
										logo.KickTxtLog(string.Concat(new object[]
										{
											"NPC广播数据 删除卡号人物：[",
											players.Userid,
											"] [",
											players.UserName,
											"]",
											this.FLD_INDEX
										}));
										players.OpClient(1);
										players.Client.Dispose();
									}
									this.PlayList.Remove(players.人物全服ID);
								}
								this.tem.Clear();
							}
						}
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "自动移动事件 出错：" + arg);
			}
		}

		private void 自动复活事件(object source, ElapsedEventArgs e)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "自动复活事件");
			}
			try
			{
				if (this.IsNpc == 1)
				{
					this.自动复活.Enabled = false;
				}
				else
				{
					this.自动移动.Enabled = true;
					if (this.NPC死亡)
					{
						this.更新NPC复活数据();
					}
				}
			}
			catch (Exception arg)
			{
				if (this.自动复活 != null)
				{
					this.自动复活.Enabled = false;
					this.自动复活.Close();
					this.自动复活.Dispose();
					this.自动复活 = null;
				}
				Form1.WriteLine(1, "自动复活事件1 出错：" + arg);
			}
			finally
			{
				if (this.自动复活 != null)
				{
					this.自动复活.Enabled = false;
					this.自动复活.Close();
					this.自动复活.Dispose();
					this.自动复活 = null;
				}
			}
		}

		private void 自动攻击事件(object source, ElapsedEventArgs e)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "自动攻击事件");
			}
			try
			{
				if (this.IsNpc != 0)
				{
					this.自动攻击.Enabled = false;
				}
				else if (this.Rxjh_HP < 0)
				{
					this.自动攻击.Enabled = false;
				}
				else if (this.FLD_AT > 0.0)
				{
					int num = (int)(this.FLD_AT * 1.22);
					Random random = new Random();
					int num2 = random.Next(1000, 2500);
					this.自动攻击.Interval = (double)num2;
					num = random.Next(num - 8, num + 8);
					Players players;
					if (World.allConnectedChars.TryGetValue(this.PlayerWid, out players))
					{
						int 攻击类型 = 28;
						if (random.Next(0, 10) < 3)
						{
							攻击类型 = 29;
							num = (int)((double)num * 1.2);
						}
						double num3 = (double)players.FLD_人物基本_防御;
						bool flag = false;
						if (players.Player_Job == 3)
						{
							double num4 = random.NextDouble();
							if (num4 <= players.枪_转攻为守)
							{
								num3 += (double)players.FLD_攻击;
							}
						}
						if (players.装备栏已穿装备[0].物品属性阶段类型 == 1)
						{
							num = (int)((double)num * (1.0 - (double)players.装备栏已穿装备[0].物品属性阶段数 / 100.0));
						}
						if ((double)num <= num3)
						{
							num = 1;
						}
						else
						{
							num -= (int)num3;
						}
						if (this.查找范围玩家(23, players))
						{
							double num5 = (double)players.FLD_装备_追加_回避 / 800.0;
							double num6 = random.NextDouble();
							if (players.Player_Job == 2)
							{
								double num7 = (double)num;
								double num8 = random.NextDouble();
								double num9 = random.NextDouble();
								if (num8 < players.剑_护身罡气)
								{
									num = (int)(num7 * 0.5);
								}
								else if (num9 < players.剑_百变神行)
								{
									num = 1;
								}
								if (num6 < num5)
								{
									num = 1;
								}
							}
							else if (num6 < num5)
							{
								num = 1;
							}
							this.发送攻击数据(num, 攻击类型, players.人物全服ID);
							if (players.人物_HP > 0 && !players._Player死亡)
							{
								players.人物_HP -= num;
								try
								{
									if (!players.追加状态列表.ContainsKey(700014))
									{
										if (players.Player_Job == 3)
										{
											if (num <= 0)
											{
												players.人物_SP += 5;
											}
											else
											{
												players.人物_SP += (int)((double)(players.FLD_装备_追加_怒气 + 8) + (double)players.人物最大_SP * players.枪_狂神降世);
											}
										}
										else if (players.Player_Job != 5)
										{
											if (num <= 0)
											{
												players.人物_SP += 4;
											}
											else
											{
												players.人物_SP += 6 + players.FLD_装备_追加_怒气;
											}
										}
									}
									if (players.Player_Job == 1)
									{
										Random random2 = new Random();
										int num10 = random2.Next(0, 101);
										if ((double)num10 <= players.反伤几率 * 100.0)
										{
											this.发送反伤攻击数据(num, players.人物全服ID);
											this.Rxjh_HP -= num;
											this.Play_Hit(players, num);
											if (this.Rxjh_HP <= 0)
											{
												flag = true;
											}
										}
									}
								}
								catch (Exception arg)
								{
									Form1.WriteLine(1, "自动攻击事件 刀反伤 出错：" + arg);
								}
								if (players.人物_HP <= 0)
								{
									this.自动攻击.Enabled = false;
									this.自动移动.Enabled = true;
									this.Rxjh_X = this.Rxjh_cs_X;
									this.Rxjh_Y = this.Rxjh_cs_Y;
									this.Rxjh_Z = this.Rxjh_cs_Z;
									this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
									players.人物_HP = 0;
									players.死亡();
									players.更新HP_MP_SP();
									players.更新人物减经验();
									if (this.PlayGjList == null)
									{
										goto IL_3D8;
									}
									using (List<PlayGjClass>.Enumerator enumerator = this.PlayGjList.GetEnumerator())
									{
										while (enumerator.MoveNext())
										{
											PlayGjClass current = enumerator.Current;
											if (current.PlayID == players.人物全服ID)
											{
												this.PlayGjList.Remove(current);
												break;
											}
										}
										goto IL_3D8;
									}
								}
								players.更新HP_MP_SP();
								IL_3D8:
								if (flag)
								{
									this.发送死亡数据(players.人物全服ID);
								}
							}
						}
						else if (this.查找原始范围())
						{
							this.自动攻击.Enabled = false;
							this.自动移动.Enabled = true;
							this.Rxjh_X = this.Rxjh_cs_X;
							this.Rxjh_Y = this.Rxjh_cs_Y;
							this.Rxjh_Z = this.Rxjh_cs_Z;
							this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
						}
						else if (this.查找范围玩家(100, players))
						{
							this.发送移动数据(players.人物坐标_X, players.人物坐标_Y, 10, 2);
						}
						else
						{
							this.自动攻击.Enabled = false;
							this.自动移动.Enabled = true;
							this.Rxjh_X = this.Rxjh_cs_X;
							this.Rxjh_Y = this.Rxjh_cs_Y;
							this.Rxjh_Z = this.Rxjh_cs_Z;
							this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
						}
					}
					else
					{
						int key = (this.PlayerWid - 40000) / 2;
						if (World.allConnectedChars.TryGetValue(key, out players))
						{
							if (players.人物灵兽 == null)
							{
								this.自动攻击.Enabled = false;
								this.自动移动.Enabled = true;
								this.Rxjh_X = this.Rxjh_cs_X;
								this.Rxjh_Y = this.Rxjh_cs_Y;
								this.Rxjh_Z = this.Rxjh_cs_Z;
								this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
							}
							else
							{
								int 攻击类型2 = 28;
								int num11 = random.Next(0, 12);
								if (num11 > 9)
								{
									攻击类型2 = 29;
									num = (int)((double)num * 1.1);
								}
								double num12 = (double)(players.人物灵兽.灵兽_防御力 * 2);
								if ((double)num <= num12)
								{
									num = 1;
								}
								else
								{
									num -= (int)num12;
								}
								if (this.查找范围玩家(30, players))
								{
									this.发送攻击数据(num, 攻击类型2, players.人物灵兽全服ID);
									players.人物灵兽.FLD_HP -= num;
									if (players.人物灵兽.FLD_HP <= 0)
									{
										players.更新灵兽HP_MP_SP();
										this.自动攻击.Enabled = false;
										this.自动移动.Enabled = true;
										this.Rxjh_X = this.Rxjh_cs_X;
										this.Rxjh_Y = this.Rxjh_cs_Y;
										this.Rxjh_Z = this.Rxjh_cs_Z;
										this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
										players.人物灵兽.FLD_HP = 0;
										players.人物灵兽.FLD_死亡 = 1;
										players.人物灵兽.保存数据();
										players.解除召唤(players, players);
										players.人物灵兽.Dispose();
										players.人物灵兽 = null;
										players.装备栏已穿装备[14].锁定 = false;
									}
									else
									{
										players.更新灵兽HP_MP_SP();
									}
								}
								else if (this.查找原始范围())
								{
									this.自动攻击.Enabled = false;
									this.自动移动.Enabled = true;
									this.Rxjh_X = this.Rxjh_cs_X;
									this.Rxjh_Y = this.Rxjh_cs_Y;
									this.Rxjh_Z = this.Rxjh_cs_Z;
									this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
								}
								else if (this.查找范围玩家(80, players))
								{
									this.发送移动数据(players.人物灵兽.人物坐标_X, players.人物灵兽.人物坐标_Y, 10, 2);
								}
								else
								{
									this.自动攻击.Enabled = false;
									this.自动移动.Enabled = true;
									this.Rxjh_X = this.Rxjh_cs_X;
									this.Rxjh_Y = this.Rxjh_cs_Y;
									this.Rxjh_Z = this.Rxjh_cs_Z;
									this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
								}
							}
						}
						else
						{
							this.自动攻击.Enabled = false;
							this.自动移动.Enabled = true;
							this.Rxjh_X = this.Rxjh_cs_X;
							this.Rxjh_Y = this.Rxjh_cs_Y;
							this.Rxjh_Z = this.Rxjh_cs_Z;
							this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
						}
					}
				}
			}
			catch (Exception arg2)
			{
				this.自动攻击.Enabled = false;
				this.自动移动.Enabled = true;
				this.Rxjh_X = this.Rxjh_cs_X;
				this.Rxjh_Y = this.Rxjh_cs_Y;
				this.Rxjh_Z = this.Rxjh_cs_Z;
				this.发送移动数据(this.Rxjh_cs_X, this.Rxjh_cs_Y, 35, 1);
				Form1.WriteLine(1, "自动攻击事件 出错：" + arg2);
			}
		}

		public List<NpcClass> 群攻查找范围Npc2(int 数量)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_群攻查找范围Npc2");
			}
			List<NpcClass> result;
			try
			{
				List<NpcClass> list = new List<NpcClass>();
				int num = 0;
				foreach (NpcClass current in MapClass.GetnpcTemplate(this.Rxjh_Map).Values)
				{
					if (!current.NPC死亡 && current.IsNpc == 0 && this.查找范围Npc(25, current) && current._FLD_INDEX != this._FLD_INDEX)
					{
						list.Add(current);
						if (num >= 数量)
						{
							break;
						}
						num++;
					}
				}
				result = list;
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "群攻查找范围Npc 出错：" + arg);
				result = null;
			}
			return result;
		}

		public void 群攻查找范围Npc()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_群攻查找范围Npc");
			}
			try
			{
				this.NpcList.Clear();
				int num = 0;
				foreach (NpcClass current in MapClass.GetnpcTemplate(this.Rxjh_Map).Values)
				{
					if (!current.NPC死亡 && current.IsNpc == 0 && this.查找范围Npc(25, current))
					{
						this.NpcList.Add(current.FLD_INDEX, current);
						if (num > 4)
						{
							break;
						}
						num++;
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "群攻查找范围Npc 出错：" + arg);
			}
		}

		public static void 更新NPC数据(Dictionary<int, NpcClass> NpcList, Players Playe)
		{
			if (NpcList == null)
			{
				return;
			}
			if (NpcList.Count <= 0)
			{
				return;
			}
			using (发包类 发包类 = new 发包类())
			{
				发包类.Write4(NpcList.Count);
				foreach (NpcClass current in NpcList.Values)
				{
					发包类.Write2(current.FLD_INDEX);
					发包类.Write2(current.FLD_INDEX);
					发包类.Write2(current.FLD_PID);
					发包类.Write4(1);
					发包类.Write4(current.Rxjh_HP);
					发包类.Write4(current.Max_Rxjh_HP);
					发包类.Write(current.Rxjh_X);
					发包类.Write(current.Rxjh_Z);
					发包类.Write(current.Rxjh_Y);
					发包类.Write4(1082130432);
					发包类.Write(current.FLD_FACE1);
					发包类.Write(current.FLD_FACE2);
					发包类.Write(current.Rxjh_X);
					发包类.Write(current.Rxjh_Z);
					发包类.Write(current.Rxjh_Y);
					发包类.Write4(0);
					发包类.Write4(0);
					发包类.Write4(0);
				}
				if (Playe.Client != null)
				{
					Playe.Client.SendPak(发包类, 26368, Playe.人物全服ID);
				}
			}
		}

		public static void 更新NPC删除数据(Dictionary<int, NpcClass> NpcList, Players Playe)
		{
			if (NpcList == null)
			{
				return;
			}
			if (NpcList.Count <= 0)
			{
				return;
			}
			using (发包类 发包类 = new 发包类())
			{

				foreach (NpcClass current in NpcList.Values)
				{
					发包类.Write4(1);
					发包类.Write2(current.FLD_INDEX);
					发包类.Write2(current.FLD_INDEX);
					发包类.Write2(current.FLD_PID);
					发包类.Write4(1);
					发包类.Write4(current.Rxjh_HP);
					发包类.Write4(current.Max_Rxjh_HP);
					发包类.Write(current.Rxjh_X);
					发包类.Write(current.Rxjh_Z);
					发包类.Write(current.Rxjh_Y);
					发包类.Write4(1082130432);
					发包类.Write(current.FLD_FACE1);
					发包类.Write(current.FLD_FACE2);
					发包类.Write(current.Rxjh_X);
					发包类.Write(current.Rxjh_Z);
					发包类.Write(current.Rxjh_Y);
					发包类.Write4(0);
					发包类.Write4(0);
					发包类.Write4(0);
				}
				if (Playe.Client != null)
				{
					Playe.Client.SendPak(发包类, 26624, Playe.人物全服ID);
				}
			}
		}

		public void 更新NPC复活数据()
		{
			try
			{
				this.NPC死亡 = false;
				if (this.自动复活 != null)
				{
					this.自动复活.Enabled = false;
					this.自动复活.Close();
					this.自动复活.Dispose();
					this.自动复活 = null;
				}
				this.Rxjh_HP = this.Max_Rxjh_HP;
				if (this._FLD_PID == 15349 || this._FLD_PID == 15350)
				{
					this.Rxjh_X = this.Rxjh_cs_X;
					this.Rxjh_Y = this.Rxjh_cs_Y;
				}
				else if (this._FLD_PID == 15121 || this._FLD_PID == 15122)
				{
					this.Rxjh_X = this.Rxjh_cs_X;
					this.Rxjh_Y = this.Rxjh_cs_Y;
				}
				else
				{
					Random random = new Random();
					int num = random.Next(0, 2);
					double num2 = random.NextDouble() * 50.0;
					double num3 = random.NextDouble() * 50.0;
					if (num == 0)
					{
						this.Rxjh_X = this.Rxjh_cs_X + (float)num2;
						this.Rxjh_Y = this.Rxjh_cs_Y + (float)num3;
					}
					else
					{
						this.Rxjh_X = this.Rxjh_cs_X - (float)num2;
						this.Rxjh_Y = this.Rxjh_cs_Y - (float)num3;
					}
				}
				this.Rxjh_Z = this.Rxjh_cs_Z;
				using (发包类 发包类 = new 发包类())
				{
					发包类.Write4(1);
					发包类.Write2(this.FLD_INDEX);
					发包类.Write2(this.FLD_INDEX);
					发包类.Write2(this.FLD_PID);
					发包类.Write4(1);
					发包类.Write4(this.Rxjh_HP);
					发包类.Write4(this.Max_Rxjh_HP);
					发包类.Write(this.Rxjh_X);
					发包类.Write(this.Rxjh_Z);
					发包类.Write(this.Rxjh_Y);
					发包类.Write4(1082130432);
					发包类.Write(this.FLD_FACE1);
					发包类.Write(this.FLD_FACE2);
					发包类.Write(this.Rxjh_X);
					发包类.Write(this.Rxjh_Z);
					发包类.Write(this.Rxjh_Y);
					发包类.Write4(0);
					this.发送当前范围广播数据(发包类, 31488, this.FLD_INDEX);
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, string.Concat(new object[]
				{
					"更新NPC复活数据 出错",
					this.FLD_PID,
					"|",
					this.Name,
					" ",
					ex.Message
				}));
			}
		}

		public void 更新死亡数据()
		{
			try
			{
				if (!this.NPC死亡)
				{
					this.NPC死亡 = true;
				}
				else if (this.一次性怪)
				{
					this.Play_null();
					this.广播NPC死亡数据();
					this.Dispose();
				}
				else
				{
					this.自动攻击.Enabled = false;
					this.自动移动.Enabled = false;
					if (this.自动复活 != null)
					{
						this.自动复活.Interval = (double)(this.FLD_NEWTIME * 1000);
						this.自动复活.Enabled = true;
					}
					else
					{
						this.自动复活 = new System.Timers.Timer((double)(this.FLD_NEWTIME * 1000));
						this.自动复活.Elapsed += new ElapsedEventHandler(this.自动复活事件);
						this.自动复活.Enabled = true;
					}
					this.Play_null();
					this.广播NPC死亡数据();
				}
			}
			catch (Exception ex)
			{
				this.广播NPC死亡数据();
				Form1.WriteLine(1, string.Concat(new object[]
				{
					"更新死亡数据 出错",
					this.FLD_PID,
					"|",
					this.Name,
					" ",
					ex
				}));
			}
		}

		private void 更新NPC死亡数据(Players Playe)
		{
			using (发包类 发包类 = new 发包类())
			{
				if (Playe.Client != null)
				{
					Playe.Client.SendPak(发包类, 34816, this.FLD_INDEX);
				}
			}
		}

		private void 广播NPC死亡数据()
		{
			using (发包类 发包类 = new 发包类())
			{
				this.发送当前范围广播数据(发包类, 34816, this.FLD_INDEX);
			}
		}

		public void 发送移动数据(float X, float Y, int sl, int 移动方式)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_发送移动数据");
			}
			try
			{
				using (发包类 发包类 = new 发包类())
				{
					Random random = new Random();
					int num = random.Next(0, 2);
					double num2 = random.NextDouble() * (double)sl;
					double num3 = random.NextDouble() * (double)sl;
					if (num == 0)
					{
						this.Rxjh_X = X + (float)num2;
						this.Rxjh_Y = Y + (float)num3;
					}
					else
					{
						this.Rxjh_X = X - (float)num2;
						this.Rxjh_Y = Y - (float)num3;
					}
					发包类.Write(this.Rxjh_X);
					发包类.Write(this.Rxjh_Y);
					发包类.Write(this.Rxjh_Z);
					发包类.Write4(-1);
					发包类.Write4(移动方式);
					发包类.Write((float)num2);
					发包类.Write4(this.Rxjh_HP);
					this.发送当前范围广播数据(发包类, 29696, this.FLD_INDEX);
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, string.Concat(new object[]
				{
					"发送移动数据 出错",
					this.FLD_PID,
					"|",
					this.Name,
					" ",
					ex.Message
				}));
			}
		}

		public void 发送攻击数据(int 攻击力, int 攻击类型, int 人物全服ID)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_发送攻击数据");
			}
			try
			{
				using (发包类 发包类 = new 发包类())
				{
					发包类.Write2(人物全服ID);
					发包类.Write2(0);
					发包类.Write4(攻击力);
					发包类.Write4(0);
					发包类.Write4(0);
					发包类.Write4(0);
					发包类.Write4(攻击类型);
					发包类.Write(this.Rxjh_X);
					发包类.Write(15f);
					发包类.Write(this.Rxjh_Y);
					发包类.Write(0);
					发包类.Write(1);
					发包类.Write2(0);
					发包类.Write4(0);
					this.发送当前范围广播数据(发包类, 3072, this.FLD_INDEX);
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, string.Concat(new object[]
				{
					"发送攻击数据 出错",
					this.FLD_PID,
					"|",
					this.Name,
					" ",
					ex
				}));
			}
		}

		public void 发送当前范围广播数据(发包类 pak, int id, int wordid)
		{
			try
			{
				if (this.PlayList != null)
				{
					foreach (Players current in this.PlayList.Values)
					{
						if (current.Client != null && current.Client.Running)
						{
							current.Client.SendPak(pak, id, wordid);
						}
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "NPC广播数据 出错3：" + arg);
			}
		}

		public void 发送死亡数据(int UserWorldId)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_发送死亡数据");
			}
			try
			{
				if (this.IsNpc != 1)
				{
					if (!this.NPC死亡)
					{
						this.NPC死亡 = true;
						try
						{
							this.获得分配经验();
							Players players;
							if (this.FLD_BOSS == 1)
							{
								if (World.allConnectedChars.TryGetValue(this.BossPlayerWid, out players))
								{
                                    int num4 = players.Player_Level - this.Level;
                                    int num5 = this.Level - players.Player_Level ;
                                    if (this.查找范围玩家(700, players)&& num4 <int.Parse(World.获得物品等级差[0])&& num5< int.Parse(World.获得物品等级差[1]))
									{
										this.暴物品(players);
									}
									else
									{
										this.暴物品(null);
									}
								}
								else
								{
									this.暴物品(null);
								}
							}
							else if (World.allConnectedChars.TryGetValue(this.UserPlayerWid, out players))
							{
								this.暴物品(players);
							}
							else
							{
								this.暴物品(null);
							}
						}
						catch (Exception)
						{
						}
					}
					if (this.一次性怪)
					{
						this.Play_null();
						this.广播NPC死亡数据();
						this.Dispose();
					}
					else
					{
						this.自动攻击.Enabled = false;
						this.自动移动.Enabled = true;
						if (World.势力战进程 == 3 && (this._FLD_PID == 15121 || this._FLD_PID == 15122))
						{
							if (this._FLD_PID == 15122)
							{
								World.势力战正分数 += 200;
							}
							else
							{
								World.势力战邪分数 += 200;
							}
						}
						if (this.自动复活 != null)
						{
							this.自动复活.Interval = (double)(this.FLD_NEWTIME * 1000);
							this.自动复活.Enabled = true;
						}
						else
						{
							this.自动复活 = new System.Timers.Timer((double)(this.FLD_NEWTIME * 1000));
							this.自动复活.Elapsed += new ElapsedEventHandler(this.自动复活事件);
							this.自动复活.Enabled = true;
						}
						this.Play_null();
						this.广播NPC死亡数据();
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, string.Concat(new object[]
				{
					"发送死亡数据 出错",
					this.FLD_PID,
					"|",
					this.Name,
					" ",
					ex.Message
				}));
			}
		}

		public void 发送反伤攻击数据(int 攻击力, int 人物ID)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_发送反伤攻击数据");
			}
			string hex = "AA55130001B73089000E003D0100000B0000000100000055AA";
			byte[] array = Converter.hexStringToByte(hex);
			Buffer.BlockCopy(BitConverter.GetBytes(this.FLD_INDEX), 0, array, 5, 2);
			Buffer.BlockCopy(BitConverter.GetBytes(人物ID), 0, array, 11, 2);
			Buffer.BlockCopy(BitConverter.GetBytes(攻击力), 0, array, 19, 2);
			this.广播数据(array, array.Length);
		}

		public byte[] 掉出物品(DropClass drop, Players yxqname)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_掉出物品");
			}
			byte[] result;
			try
			{


				if (yxqname .离线挂机打怪模式  == 1)//离线掉落提示
				{
					string msg = ("恭喜玩家[" + yxqname.UserName + "]获得[" + drop.FLD_NAME + "]他(她)正在[" + 坐标Class.getmapname(yxqname.人物坐标_地图) + "]击杀怪物:" + this.Name );
					World.conn.发送("掉落全线提示|" + msg + "|" + World.服务器ID + "线传言");
					//World.系统全局提示("江湖传言", "恭喜玩家[" + players.UserName + "]获得[" + itme.WPname + "]他(她)正在[" + 坐标Class.getmapname(players.人物坐标_地图) + "]击杀怪物:" + itme.NPCname, 23);
					//RxjhClass.掉落记录(players.Userid, players.UserName, World.服务器名, num, itme.WPname, itme.NPCname, "怪物掉落");
					//Form1.WriteLine(44, "玩家 [" + players.Userid + "][" + players.UserName + "]获得物品[" + itme.WPname + "]地图[" + 坐标Class.getmapname(players.人物坐标_地图) + "]击杀怪物:" + itme.NPCname + "]编号 ：" + num + " [" + itme.物品.得到物品名称() + "] 数量：" + BitConverter.ToInt32(itme.物品.物品数量, 0));
				}

				


				long dBItmeId = RxjhClass.GetDBItmeId();
				byte[] array = new byte[73];
				byte[] bytes = BitConverter.GetBytes(dBItmeId);
				byte[] array2 = new byte[56];
				ItmeClass itmeClass;
				if (World.Itme.TryGetValue(drop.FLD_PID, out itmeClass))
				{
					if (itmeClass.FLD_QUESTITEM == 1)
					{
						if (yxqname != null)
						{
							if (yxqname.组队id != 0)
							{
								组队Class 组队Class;
								if (!World.W组队.TryGetValue(yxqname.组队id, out 组队Class))
								{
									goto IL_F4;
								}
								using (Dictionary<int, Players>.ValueCollection.Enumerator enumerator = 组队Class.组队列表.Values.GetEnumerator())
								{
									while (enumerator.MoveNext())
									{
										Players current = enumerator.Current;
										if (this.查找范围玩家(700, current) && current.检查任务是否匹配(drop.FLD_PID))
										{
											current.设置任务物品(drop.FLD_PID, 1);
										}
									}
									goto IL_F4;
								}
							}
							if (yxqname.检查任务是否匹配(drop.FLD_PID))
							{
								yxqname.设置任务物品(drop.FLD_PID, 1);
							}
						}
						IL_F4:
						result = null;
						return result;
					}
					try
					{
						if (World.Droplog)
						{
							Form1.WriteLine(4, string.Concat(new object[]
							{
								"物品掉落--物品名:",
								drop.FLD_NAME,
								" 属性1[",
								drop.FLD_MAGIC0,
								"]属性2[",
								drop.FLD_MAGIC1,
								"]属性3[",
								drop.FLD_MAGIC2,
								"]属性4[",
								drop.FLD_MAGIC3,
								"]属性5[",
								drop.FLD_MAGIC4,
								"]"
							}));
						}
						Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC0), 0, array2, 0, 4);
						Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC1), 0, array2, 4, 4);
						Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC2), 0, array2, 8, 4);
						Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC3), 0, array2, 12, 4);
						Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC4), 0, array2, 16, 4);
						Buffer.BlockCopy(bytes, 0, array, 0, 4);
						Buffer.BlockCopy(array2, 0, array, 16, 56);
						Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_PID), 0, array, 8, 4);
						Buffer.BlockCopy(BitConverter.GetBytes(1), 0, array, 12, 4);
					}
					catch (Exception ex)
					{
						Form1.WriteLine(1, string.Concat(new object[]
						{
							"掉出物品1 出错 ",
							this.FLD_PID,
							"|",
							this.Name,
							" ",
							ex.Message
						}));
						result = null;
						return result;
					}
					地面物品类 地面物品类;
					try
					{
						地面物品类 = new 地面物品类(array, this.Rxjh_X, this.Rxjh_Y, this.Rxjh_Z, this.Rxjh_Map, yxqname, drop.是否提示, this.Name, drop.FLD_NAME);
						if (地面物品类 == null)
						{
							Form1.WriteLine(1, string.Concat(new object[]
							{
								"掉出物品2 出错 ",
								this.FLD_PID,
								"|",
								this.Name
							}));
							result = null;
							return result;
						}
						if (!World.ItmeTeM.ContainsKey(dBItmeId))
						{
							World.ItmeTeM.Add(dBItmeId, 地面物品类);
						}
					}
					catch (Exception ex2)
					{
						Form1.WriteLine(1, string.Concat(new object[]
						{
							"掉出物品3 出错 ",
							this.FLD_PID,
							"|",
							this.Name,
							" ",
							ex2.Message
						}));
						result = null;
						return result;
					}
					try
					{
						if (World.ItmeTeM.ContainsKey(dBItmeId))
						{
							地面物品类.获取范围玩家发送地面增加物品数据包();
						}
						result = array;
						return result;
					}
					catch (Exception ex3)
					{
						Form1.WriteLine(1, string.Concat(new object[]
						{
							"掉出物品4 出错 ",
							this.FLD_PID,
							"|",
							this.Name,
							" ",
							ex3.Message
						}));
						result = null;
						return result;
					}
				}
				result = null;
			}
			catch (Exception ex4)
			{
				Form1.WriteLine(1, string.Concat(new object[]
				{
					"掉出物品5 出错 ",
					this.FLD_PID,
					"|",
					this.Name,
					" ",
					ex4.Message
				}));
				result = null;
			}
			finally
			{
				drop.FLD_MAGIC0 = drop.FLD_MAGICNew0;
				drop.FLD_MAGIC1 = drop.FLD_MAGICNew1;
				drop.FLD_MAGIC2 = drop.FLD_MAGICNew2;
				drop.FLD_MAGIC3 = drop.FLD_MAGICNew3;
				drop.FLD_MAGIC4 = drop.FLD_MAGICNew4;
			}
			return result;
		}

		public void 暴物品(Players yxqname)
		{
			try
			{
				if (yxqname != null && World.死亡复活锁定时间 > 0)
				{
					int num = (int)DateTime.Now.Subtract(yxqname.复活时间).TotalSeconds;
					if (num <= World.死亡复活锁定时间)
					{
						return;
					}
				}
				using (new Lock(this.AsyncLock, "死亡掉落"))
				{
					if (yxqname != null)
					{
						DropClass rwDrop = DropClass.GetRwDrop(yxqname, this.FLD_PID);
						ItmeClass itmeClass;
						if (rwDrop != null && World.Itme.TryGetValue(rwDrop.FLD_PID, out itmeClass) && itmeClass.FLD_QUESTITEM == 1 && yxqname != null)
						{
							if (yxqname.组队id != 0)
							{
								组队Class 组队Class;
								if (!World.W组队.TryGetValue(yxqname.组队id, out 组队Class))
								{
									goto IL_124;
								}
								using (Dictionary<int, Players>.ValueCollection.Enumerator enumerator = 组队Class.组队列表.Values.GetEnumerator())
								{
									while (enumerator.MoveNext())
									{
										Players current = enumerator.Current;
										if (this.查找范围玩家(700, current) && current.检查任务是否匹配(rwDrop.FLD_PID))
										{
											current.设置任务物品(rwDrop.FLD_PID, 1);
										}
									}
									goto IL_124;
								}
							}
							if (yxqname.检查任务是否匹配(rwDrop.FLD_PID))
							{
								yxqname.设置任务物品(rwDrop.FLD_PID, 1);
							}
						}
						IL_124:
						if (this.FLD_BOSS == 0)
						{
							if (yxqname.Player_Level - this.Level < World.人怪等级差最小限制 && this.Level - yxqname.Player_Level < 21)
							{
								this.暴物品2(yxqname);
							}
						}
						else if (this.FLD_BOSS == 1)
						{
							this.Boss暴物品(yxqname);
						}
						else if (this.FLD_BOSS == 2 && yxqname.Player_Level - this.Level < World.人怪等级差最小限制 && this.Level - yxqname.Player_Level < 21)
						{
							this.GS暴物品(1, 3, yxqname);
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		public void GS暴物品(int sl, int maxsl, Players yxqname)
		{
			try
			{
				if (this.Rxjh_Exp > 0)
				{
					int num = this.Randomd.Next(1, 4000);
					if (num <= World.暴率)
					{
						List<DropClass> gSDrop = DropClass.GetGSDrop(this.Level, sl, maxsl, this.FLD_PID);
						foreach (DropClass current in gSDrop)
						{
							if (current != null)
							{
								int fLD_PID = current.FLD_PID;
								switch (fLD_PID)
								{
								case 800000011:
								{
									int num2 = new Random().Next(0, 101);
									int fLD_MAGIC;
									if (num2 == 100)
									{
										fLD_MAGIC = 100015;
										new Random().Next(20, 27);
									}
									else if (num2 > 97)
									{
										fLD_MAGIC = 100014;
									}
									else if (num2 > 94)
									{
										fLD_MAGIC = 100013;
									}
									else if (num2 > 91)
									{
										fLD_MAGIC = 100012;
									}
									else if (num2 > 87)
									{
										fLD_MAGIC = 100011;
									}
									else if (num2 > 82)
									{
										fLD_MAGIC = 100010;
									}
									else
									{
										fLD_MAGIC = new Random().Next(100005, 100010);
									}
									current.FLD_PID = 800000001;
									current.FLD_MAGIC0 = fLD_MAGIC;
									break;
								}
								case 800000012:
								{
									int num3 = new Random().Next(0, 101);
									int fLD_MAGIC2;
									if (num3 > 99)
									{
										fLD_MAGIC2 = 200008;
										new Random().Next(20, 27);
										current.是否提示 = 1;
									}
									else if (num3 > 95)
									{
										fLD_MAGIC2 = 200007;
									}
									else if (num3 > 88)
									{
										fLD_MAGIC2 = 200006;
									}
									else if (num3 > 80)
									{
										fLD_MAGIC2 = 200005;
									}
									else
									{
										fLD_MAGIC2 = new Random().Next(200001, 200005);
									}
									current.FLD_PID = 800000002;
									current.FLD_MAGIC0 = fLD_MAGIC2;
									break;
								}
								case 800000013:
									if (current.FLD_MAGIC0 == 0)
									{
										int num4 = this.Randomd.Next(8010, 8060);
										current.FLD_MAGIC0 = num4 * 100 + 1;
									}
									break;
								default:
									switch (fLD_PID)
									{
									case 800000025:
									{
										int num5 = new Random().Next(0, 201);
										int fLD_MAGIC3;
										if (num5 > 198)
										{
											new Random().Next(20, 27);
											fLD_MAGIC3 = 1000020;
										}
										else if (num5 > 195)
										{
											fLD_MAGIC3 = 1000019;
										}
										else if (num5 > 190)
										{
											fLD_MAGIC3 = 1000018;
										}
										else if (num5 > 182)
										{
											fLD_MAGIC3 = 1000017;
										}
										else if (num5 > 175)
										{
											fLD_MAGIC3 = 1000016;
										}
										else if (num5 > 160)
										{
											fLD_MAGIC3 = 1000015;
										}
										else
										{
											fLD_MAGIC3 = new Random().Next(1000005, 1000018);
										}
										current.FLD_PID = 800000001;
										current.FLD_MAGIC0 = fLD_MAGIC3;
										break;
									}
									case 800000026:
									{
										int num6 = new Random().Next(0, 201);
										int fLD_MAGIC4;
										if (num6 == 200)
										{
											new Random().Next(20, 27);
											current.是否提示 = 1;
											fLD_MAGIC4 = 700025;
										}
										else if (num6 > 197)
										{
											fLD_MAGIC4 = 700024;
										}
										else if (num6 > 193)
										{
											fLD_MAGIC4 = 700023;
										}
										else if (num6 > 185)
										{
											fLD_MAGIC4 = 700022;
										}
										else if (num6 > 173)
										{
											fLD_MAGIC4 = 700021;
										}
										else if (num6 > 155)
										{
											fLD_MAGIC4 = 700020;
										}
										else
										{
											fLD_MAGIC4 = new Random().Next(700010, 700020);
										}
										current.FLD_PID = 800000001;
										current.FLD_MAGIC0 = fLD_MAGIC4;
										break;
									}
									case 800000028:
										if (current.FLD_MAGIC0 == 0)
										{
											int num7 = this.Randomd.Next(1, 7);
											string str = "200";
											string str2 = "000";
											string s = str + num7.ToString() + str2;
											current.FLD_MAGIC0 = int.Parse(s);
										}
										break;
									case 800000034:
									{
										Random random = new Random();
										int num8 = random.Next(0, 7);
										switch (num8)
										{
										case 0:
										case 1:
											num8 = 1;
											break;
										case 2:
										case 6:
											num8 = 3;
											break;
										case 3:
											num8 = 5;
											break;
										case 4:
											num8 = 7;
											break;
										case 5:
											num8 = 10;
											break;
										}
										int num9 = random.Next(10, 21);
										current.FLD_MAGIC0 = num8 * 100000 + num9;
										current.FLD_PID = 800000030;
										break;
									}
									case 800000035:
									{
										Random random2 = new Random();
										int num10 = random2.Next(0, 7);
										switch (num10)
										{
										case 0:
										case 1:
											num10 = 1;
											break;
										case 2:
										case 6:
											num10 = 3;
											break;
										case 3:
											num10 = 5;
											break;
										case 4:
											num10 = 7;
											break;
										case 5:
											num10 = 10;
											break;
										}
										int num11 = random2.Next(15, 26);
										current.FLD_MAGIC0 = num10 * 100000 + num11;
										current.FLD_PID = 800000031;
										break;
									}
									case 800000036:
									{
										Random random3 = new Random();
										int num12 = random3.Next(0, 7);
										switch (num12)
										{
										case 0:
										case 1:
											num12 = 2;
											break;
										case 2:
										case 6:
											num12 = 3;
											break;
										case 3:
											num12 = 4;
											break;
										case 4:
											num12 = 6;
											break;
										case 5:
											num12 = 11;
											break;
										}
										int num13 = random3.Next(8, 11);
										current.FLD_MAGIC0 = num12 * 100000 + num13;
										current.FLD_PID = 800000032;
										break;
									}
									case 800000037:
									{
										Random random4 = new Random();
										int num14 = random4.Next(0, 7);
										switch (num14)
										{
										case 0:
										case 1:
											num14 = 2;
											break;
										case 2:
										case 6:
											num14 = 3;
											break;
										case 3:
											num14 = 4;
											break;
										case 4:
											num14 = 6;
											break;
										case 5:
											num14 = 11;
											break;
										}
										int num15 = random4.Next(10, 16);
										current.FLD_MAGIC0 = num14 * 100000 + num15;
										current.FLD_PID = 800000033;
										break;
									}
									}
									break;
								}
								this.掉出物品(current, yxqname);
							}
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		public void BossPlayerDrop()
		{
			try
			{
				DropClass dropClass = BOSS地图.获得BOSS持有物品(this.Rxjh_Map, this.FLD_PID);
				if (dropClass != null)
				{
					new List<Players>();
					int num = this.Max_Rxjh_HP / this.PlayGjList.Count / 2;
					foreach (PlayGjClass current in this.PlayGjList)
					{
						Players players;
						if (current.Hitsl >= num && World.allConnectedChars.TryGetValue(current.PlayID, out players) && this.查找范围玩家(700, players))
						{
							this.掉出物品(dropClass, players);
						}
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(0, "BossPlayerDrop error " + arg);
			}
		}

		public void Boss暴物品(Players yxqname)
		{
			try
			{
				if (this.Rxjh_Exp > 0)
				{
					if (BOSS地图.cheekBossMap(this.Rxjh_Map))
					{
						this.BossPlayerDrop();
					}
					List<DropClass> bossDrop = DropClass.GetBossDrop(yxqname.Player_Level, this.FLD_PID);
					foreach (DropClass current in bossDrop)
					{
						if (current != null)
						{
							int fLD_PID = current.FLD_PID;
							switch (fLD_PID)
							{
							case 800000011:
							{
								int num = new Random().Next(0, 101);
								int fLD_MAGIC;
								if (num == 100)
								{
									fLD_MAGIC = 100015;
									new Random().Next(20, 27);
								}
								else if (num > 97)
								{
									fLD_MAGIC = 100014;
								}
								else if (num > 94)
								{
									fLD_MAGIC = 100013;
								}
								else if (num > 91)
								{
									fLD_MAGIC = 100012;
								}
								else if (num > 87)
								{
									fLD_MAGIC = 100011;
								}
								else if (num > 82)
								{
									fLD_MAGIC = 100010;
								}
								else
								{
									fLD_MAGIC = new Random().Next(100005, 100010);
								}
								current.FLD_PID = 800000001;
								current.FLD_MAGIC0 = fLD_MAGIC;
								break;
							}
							case 800000012:
							{
								int num2 = new Random().Next(0, 101);
								int fLD_MAGIC2;
								if (num2 > 99)
								{
									fLD_MAGIC2 = 200008;
									new Random().Next(20, 27);
									current.是否提示 = 1;
								}
								else if (num2 > 95)
								{
									fLD_MAGIC2 = 200007;
								}
								else if (num2 > 88)
								{
									fLD_MAGIC2 = 200006;
								}
								else if (num2 > 80)
								{
									fLD_MAGIC2 = 200005;
								}
								else
								{
									fLD_MAGIC2 = new Random().Next(200001, 200005);
								}
								current.FLD_PID = 800000002;
								current.FLD_MAGIC0 = fLD_MAGIC2;
								break;
							}
							case 800000013:
								if (current.FLD_MAGIC0 == 0)
								{
									int num3 = this.Randomd.Next(8010, 8060);
									current.FLD_MAGIC0 = num3 * 100 + 1;
								}
								break;
							default:
								switch (fLD_PID)
								{
								case 800000025:
								{
									int num4 = new Random().Next(0, 201);
									int fLD_MAGIC3;
									if (num4 > 198)
									{
										new Random().Next(20, 27);
										fLD_MAGIC3 = 1000020;
									}
									else if (num4 > 195)
									{
										fLD_MAGIC3 = 1000019;
									}
									else if (num4 > 190)
									{
										fLD_MAGIC3 = 1000018;
									}
									else if (num4 > 182)
									{
										fLD_MAGIC3 = 1000017;
									}
									else if (num4 > 175)
									{
										fLD_MAGIC3 = 1000016;
									}
									else if (num4 > 160)
									{
										fLD_MAGIC3 = 1000015;
									}
									else
									{
										fLD_MAGIC3 = new Random().Next(1000005, 1000018);
									}
									current.FLD_PID = 800000001;
									current.FLD_MAGIC0 = fLD_MAGIC3;
									break;
								}
								case 800000026:
								{
									int num5 = new Random().Next(0, 201);
									int fLD_MAGIC4;
									if (num5 == 200)
									{
										new Random().Next(20, 27);
										current.是否提示 = 1;
										fLD_MAGIC4 = 700025;
									}
									else if (num5 > 197)
									{
										fLD_MAGIC4 = 700024;
									}
									else if (num5 > 193)
									{
										fLD_MAGIC4 = 700023;
									}
									else if (num5 > 185)
									{
										fLD_MAGIC4 = 700022;
									}
									else if (num5 > 173)
									{
										fLD_MAGIC4 = 700021;
									}
									else if (num5 > 155)
									{
										fLD_MAGIC4 = 700020;
									}
									else
									{
										fLD_MAGIC4 = new Random().Next(700010, 700020);
									}
									current.FLD_PID = 800000001;
									current.FLD_MAGIC0 = fLD_MAGIC4;
									break;
								}
								case 800000028:
									if (current.FLD_MAGIC0 == 0)
									{
										int num6 = this.Randomd.Next(1, 7);
										string str = "200";
										string str2 = "000";
										string s = str + num6.ToString() + str2;
										current.FLD_MAGIC0 = int.Parse(s);
									}
									break;
								case 800000034:
								{
									Random random = new Random();
									int num7 = random.Next(0, 7);
									switch (num7)
									{
									case 0:
									case 1:
										num7 = 1;
										break;
									case 2:
									case 6:
										num7 = 3;
										break;
									case 3:
										num7 = 5;
										break;
									case 4:
										num7 = 7;
										break;
									case 5:
										num7 = 10;
										break;
									}
									int num8 = random.Next(10, 21);
									current.FLD_MAGIC0 = num7 * 100000 + num8;
									current.FLD_PID = 800000030;
									break;
								}
								case 800000035:
								{
									Random random2 = new Random();
									int num9 = random2.Next(0, 7);
									switch (num9)
									{
									case 0:
									case 1:
										num9 = 1;
										break;
									case 2:
									case 6:
										num9 = 3;
										break;
									case 3:
										num9 = 5;
										break;
									case 4:
										num9 = 7;
										break;
									case 5:
										num9 = 10;
										break;
									}
									int num10 = random2.Next(15, 26);
									current.FLD_MAGIC0 = num9 * 100000 + num10;
									current.FLD_PID = 800000031;
									break;
								}
								case 800000036:
								{
									Random random3 = new Random();
									int num11 = random3.Next(0, 7);
									switch (num11)
									{
									case 0:
									case 1:
										num11 = 2;
										break;
									case 2:
									case 6:
										num11 = 3;
										break;
									case 3:
										num11 = 4;
										break;
									case 4:
										num11 = 6;
										break;
									case 5:
										num11 = 11;
										break;
									}
									int num12 = random3.Next(8, 11);
									current.FLD_MAGIC0 = num11 * 100000 + num12;
									current.FLD_PID = 800000032;
									break;
								}
								case 800000037:
								{
									Random random4 = new Random();
									int num13 = random4.Next(0, 7);
									switch (num13)
									{
									case 0:
									case 1:
										num13 = 2;
										break;
									case 2:
									case 6:
										num13 = 3;
										break;
									case 3:
										num13 = 4;
										break;
									case 4:
										num13 = 6;
										break;
									case 5:
										num13 = 11;
										break;
									}
									int num14 = random4.Next(10, 16);
									current.FLD_MAGIC0 = num13 * 100000 + num14;
									current.FLD_PID = 800000033;
									break;
								}
								}
								break;
							}
							this.掉出物品(current, yxqname);
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		public void 暴物品2(Players yxqname)
		{
			try
			{
				if (this.Rxjh_Exp > 0)
				{
					if (yxqname.Player_LockState != 0)
					{
						double num = World.暴率;
						if (this.Rxjh_Map == 1301 || this.Rxjh_Map == 5001)
						{
							num = (int)((double)World.暴率 * 1.1);
						}
						int num2 = this.Randomd.Next(1, 8000);
						if (yxqname != null)
						{
                            if(yxqname.Player_Job ==1)
                            {
                                num = num * World.刀客暴率百分比;
                            }
							

                          if(yxqname.FLD_人物_追加_爆率百分比 != 0)
                            {
                                num += num * yxqname.FLD_人物_追加_爆率百分比;
                            }
                            if (yxqname.检查公有药品())
							{
								num = num * 11 / 10;
							}
							double num3 = 0.0;
							int num4 = 0;
							int num5 = 0;
							bool flag = false;
							if (yxqname.组队id != 0)
							{
								组队Class 组队Class;
								if (World.W组队.TryGetValue(yxqname.组队id, out 组队Class))
								{
									int num6 = 0;
									int num7 = 0;
									int num8 = 0;
									int num9 = 0;
									int num10 = 0;
									int num11 = 0;
									foreach (Players current in 组队Class.组队列表.Values)
									{
										if (current.Player_Job != 1)
										{
											if (current.Player_Job == 4 || current.Player_Job == 5)
											{
												num5++;
											}
										}
										else if (current.Player_Level >= 55)
										{
											num4++;
										}
										if (this.查找范围玩家(700, current))
										{
											if (current.Player_Job == 5 && current.Player_Job_leve > 3 && current.医_天佑之气 > num3)
											{
												num3 = current.医_天佑之气;
											}
											num11++;
											if (current.Player_Job == 5)
											{
												num7++;
											}
											else if (current.Player_Job == 4)
											{
												num6++;
											}
											else if (current.Player_Job == 3)
											{
												num8++;
											}
											else if (current.Player_Job == 2)
											{
												num9++;
											}
											else if (current.Player_Job == 1)
											{
												num10++;
											}
										}
									}
									flag = (num5 != 0 && num7 != 0 && num8 != 0 && num9 != 0 && num10 != 0);
								}
							}
							else if (yxqname.Player_Job == 5 && yxqname.Player_Job_leve > 3)
							{
								num3 = yxqname.医_天佑之气;
							}
							else if (yxqname.Player_Job == 4)
							{
								num = num * 9 / 10;
							}
							num2 -= (int)((double)num2 * num3);
							if (yxqname.Player_Job == 1)
							{
								num2 = num2 * 11 / 10;
							}
							else if (yxqname.Player_Job == 4)
							{
								if (yxqname.检查公有药品())
								{
									num2 = num2 * 11 / 10;
								}
								else
								{
									num2 = num2 * 13 / 10;
								}
							}
							if (flag)
							{
								num2 = num2 * 10 / 12;
							}
							if (this.Level > yxqname.Player_Level)
							{
								num2 = num2 * 12 / 10;
							}
							if (num4 > 2)
							{
								if (num4 == 8)
								{
									num2 = 8000;
								}
								else
								{
									num2 = num2 * (num4 + 4) / (8 - num4);
								}
							}
							if (num5 > 2)
							{
								if (num5 == 8)
								{
									num2 = 8000;
								}
								else
								{
									num2 = num2 * (num5 + 4) / (8 - num5);
								}
							}
						}
						if (num2 <= num)
						{
							DropClass drop = DropClass.GetDrop(yxqname, this.Level, this.FLD_PID);
							if (drop != null)
							{
								int fLD_PID = drop.FLD_PID;
								switch (fLD_PID)
								{
								case 800000011:
								{
									int num12 = new Random().Next(0, 101);
									int fLD_MAGIC;
									if (num12 == 100)
									{
										fLD_MAGIC = 100015;
										new Random().Next(20, 27);
									}
									else if (num12 > 97)
									{
										fLD_MAGIC = 100014;
									}
									else if (num12 > 94)
									{
										fLD_MAGIC = 100013;
									}
									else if (num12 > 91)
									{
										fLD_MAGIC = 100012;
									}
									else if (num12 > 87)
									{
										fLD_MAGIC = 100011;
									}
									else if (num12 > 82)
									{
										fLD_MAGIC = 100010;
									}
									else
									{
										fLD_MAGIC = new Random().Next(100005, 100010);
									}
									drop.FLD_PID = 800000001;
									drop.FLD_MAGIC0 = fLD_MAGIC;
									break;
								}
								case 800000012:
								{
									int num13 = new Random().Next(0, 101);
									int fLD_MAGIC2;
									if (num13 > 99)
									{
										fLD_MAGIC2 = 200008;
										new Random().Next(20, 27);
										drop.是否提示 = 1;
									}
									else if (num13 > 95)
									{
										fLD_MAGIC2 = 200007;
									}
									else if (num13 > 88)
									{
										fLD_MAGIC2 = 200006;
									}
									else if (num13 > 80)
									{
										fLD_MAGIC2 = 200005;
									}
									else
									{
										fLD_MAGIC2 = new Random().Next(200001, 200005);
									}
									drop.FLD_PID = 800000002;
									drop.FLD_MAGIC0 = fLD_MAGIC2;
									break;
								}
								case 800000013:
									if (drop.FLD_MAGIC0 == 0)
									{
										int num14 = this.Randomd.Next(8010, 8060);
										drop.FLD_MAGIC0 = num14 * 100 + 1;
									}
									break;
								default:
									switch (fLD_PID)
									{
									case 800000025:
									{
										int num15 = new Random().Next(0, 201);
										int fLD_MAGIC3;
										if (num15 > 198)
										{
											new Random().Next(20, 27);
											fLD_MAGIC3 = 1000020;
										}
										else if (num15 > 195)
										{
											fLD_MAGIC3 = 1000019;
										}
										else if (num15 > 190)
										{
											fLD_MAGIC3 = 1000018;
										}
										else if (num15 > 182)
										{
											fLD_MAGIC3 = 1000017;
										}
										else if (num15 > 175)
										{
											fLD_MAGIC3 = 1000016;
										}
										else if (num15 > 160)
										{
											fLD_MAGIC3 = 1000015;
										}
										else
										{
											fLD_MAGIC3 = new Random().Next(1000005, 1000018);
										}
										drop.FLD_PID = 800000001;
										drop.FLD_MAGIC0 = fLD_MAGIC3;
										break;
									}
									case 800000026:
									{
										int num16 = new Random().Next(0, 201);
										int fLD_MAGIC4;
										if (num16 == 200)
										{
											new Random().Next(20, 27);
											drop.是否提示 = 1;
											fLD_MAGIC4 = 700025;
										}
										else if (num16 > 197)
										{
											fLD_MAGIC4 = 700024;
										}
										else if (num16 > 193)
										{
											fLD_MAGIC4 = 700023;
										}
										else if (num16 > 185)
										{
											fLD_MAGIC4 = 700022;
										}
										else if (num16 > 173)
										{
											fLD_MAGIC4 = 700021;
										}
										else if (num16 > 155)
										{
											fLD_MAGIC4 = 700020;
										}
										else
										{
											fLD_MAGIC4 = new Random().Next(700010, 700020);
										}
										drop.FLD_PID = 800000001;
										drop.FLD_MAGIC0 = fLD_MAGIC4;
										break;
									}
									case 800000028:
										if (drop.FLD_MAGIC0 == 0)
										{
											int num17 = this.Randomd.Next(1, 7);
											string str = "200";
											string str2 = "000";
											string s = str + num17.ToString() + str2;
											drop.FLD_MAGIC0 = int.Parse(s);
										}
										break;
									case 800000034:
									{
										Random random = new Random();
										int num18 = random.Next(0, 7);
										switch (num18)
										{
										case 0:
										case 1:
											num18 = 1;
											break;
										case 2:
										case 6:
											num18 = 3;
											break;
										case 3:
											num18 = 5;
											break;
										case 4:
											num18 = 7;
											break;
										case 5:
											num18 = 10;
											break;
										}
										int num19 = random.Next(10, 21);
										drop.FLD_MAGIC0 = num18 * 100000 + num19;
										drop.FLD_PID = 800000030;
										break;
									}
									case 800000035:
									{
										Random random2 = new Random();
										int num20 = random2.Next(0, 7);
										switch (num20)
										{
										case 0:
										case 1:
											num20 = 1;
											break;
										case 2:
										case 6:
											num20 = 3;
											break;
										case 3:
											num20 = 5;
											break;
										case 4:
											num20 = 7;
											break;
										case 5:
											num20 = 10;
											break;
										}
										int num21 = random2.Next(15, 26);
										drop.FLD_MAGIC0 = num20 * 100000 + num21;
										drop.FLD_PID = 800000031;
										break;
									}
									case 800000036:
									{
										Random random3 = new Random();
										int num22 = random3.Next(0, 7);
										switch (num22)
										{
										case 0:
										case 1:
											num22 = 2;
											break;
										case 2:
										case 6:
											num22 = 3;
											break;
										case 3:
											num22 = 4;
											break;
										case 4:
											num22 = 6;
											break;
										case 5:
											num22 = 11;
											break;
										}
										int num23 = random3.Next(8, 11);
										drop.FLD_MAGIC0 = num22 * 100000 + num23;
										drop.FLD_PID = 800000032;
										break;
									}
									case 800000037:
									{
										Random random4 = new Random();
										int num24 = random4.Next(0, 7);
										switch (num24)
										{
										case 0:
										case 1:
											num24 = 2;
											break;
										case 2:
										case 6:
											num24 = 3;
											break;
										case 3:
											num24 = 4;
											break;
										case 4:
											num24 = 6;
											break;
										case 5:
											num24 = 11;
											break;
										}
										int num25 = random4.Next(10, 16);
										drop.FLD_MAGIC0 = num24 * 100000 + num25;
										drop.FLD_PID = 800000033;
										break;
									}
									}
									break;
								}

								
								
								this.掉出物品(drop, yxqname);
							}
						}
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "普通怪暴物品 出错：" + arg);
			}
		}

		public bool 查找范围Npc(int far_, NpcClass Npc)
		{
			if (Npc.Rxjh_Map == this.Rxjh_Map)
			{
				float num = Npc.Rxjh_X - this.Rxjh_X;
				float num2 = Npc.Rxjh_Y - this.Rxjh_Y;
				float num3 = (float)((int)Math.Sqrt((double)(num * num + num2 * num2)));
				return num3 <= (float)far_;
			}
			return false;
		}

		public bool 查找范围玩家(int far_, Players Playe)
		{
			try
			{
				if (Playe.人物坐标_地图 != this.Rxjh_Map)
				{
					bool result = false;
					return result;
				}
				if (Playe.Player死亡)
				{
					bool result = false;
					return result;
				}
				if (Playe.人物坐标_地图 == 7101)
				{
					far_ = 1000;
				}
				float num = Playe.人物坐标_X - this.Rxjh_X;
				float num2 = Playe.人物坐标_Y - this.Rxjh_Y;
				float num3 = (float)((int)Math.Sqrt((double)(num * num + num2 * num2)));
				if (num3 <= (float)far_)
				{
					bool result = true;
					return result;
				}
			}
			catch
			{
			}
			return false;
		}

		public bool 查找原始范围()
		{
			try
			{
				if ((double)World.怪物移动最大范围 < 1.0)
				{
					bool result = false;
					return result;
				}
				float num = this.Rxjh_cs_X - this.Rxjh_X;
				float num2 = this.Rxjh_cs_Y - this.Rxjh_Y;
				float num3 = (float)((int)Math.Sqrt((double)(num * num + num2 * num2)));
				if (num3 > World.怪物移动最大范围)
				{
					bool result = true;
					return result;
				}
			}
			catch
			{
			}
			return false;
		}

		public bool 查找范围玩家(int far_, 灵兽类 Playe)
		{
			if (Playe.人物坐标_MAP == this.Rxjh_Map)
			{
				float num = Playe.人物坐标_X - this.Rxjh_X;
				float num2 = Playe.人物坐标_Y - this.Rxjh_Y;
				float num3 = (float)((int)Math.Sqrt((double)(num * num + num2 * num2)));
				return num3 <= (float)far_;
			}
			return false;
		}

		public bool 获取范围玩家()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_获取范围玩家");
			}
			try
			{
				foreach (Players current in World.allConnectedChars.Values)
				{
					if (this.Level >= current.Player_Level - 20 && current.人物_HP > 0 && this.查找范围玩家(90, current))
					{
						this.Play_Add(current);
						bool result = true;
						return result;
					}
				}
			}
			catch (Exception)
			{
				bool result = false;
				return result;
			}
			return false;
		}

		public void 广播数据(byte[] data, int length)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(0, "NpcClass_广播数据2");
			}
			try
			{
				foreach (Players current in this.PlayList.Values)
				{
					if (current.Client != null && current.Client.Running)
					{
						current.Client.Send(data, length);
					}
				}
			}
			catch (Exception arg)
			{
				Form1.WriteLine(1, "NPC广播数据2 出错2：" + arg);
			}
		}
	}
}
